﻿using Oracle.ManagedDataAccess.Client;
using System;
using System.Configuration;
using System.Data.Common;
using System.Data.Odbc;
using System.Data.SqlClient;
using System.Data.SQLite;
using System.Text;

namespace UPos.Core
{
    static class ExtendHelper
    {
        public static OracleParameter OP(this string name, object value)
        {
            return new OracleParameter(":" + name, value);
        }

        public static SqlParameter SP(this string name, object value)
        {
            return new SqlParameter("@" + name, value);
        }

        public static OdbcParameter ODP(this string name, object value)
        {
            return new OdbcParameter("@" + name, value);
        }

        public static SQLiteParameter SLP(this string name, object value)
        {
            return new SQLiteParameter("@" + name, value);
        }

        internal static string Decode(this ConnectionStringSettings setting)
        {
            string decode = null;
            byte[] bytes = Convert.FromBase64String(setting.ConnectionString);
            try
            {
                decode = Encoding.UTF8.GetString(bytes);
            }
            catch
            {
                decode = setting.ConnectionString;
            }
            return decode;
        }
    }
}
